package vistop.datatypes;


public class Directed<T extends GeometricalObject> {
	private T type;
	private T go;
	private int dir;
	
	public Directed(T geometricalObject, int direction) {
		this.go = geometricalObject;
		this.dir = direction;
	}
	
	public T getGeometricalObject() {
		return this.go;
	}
	
	public int getDirection() {
		return this.dir;
	}
	
	public Vertex getStart() throws NoSuchFieldException {
		if (this.go instanceof Edge) {
			return dir > 0 ? ((Edge) go).getStart() : ((Edge) go).getEnd();
		}
		throw new NoSuchFieldException("This method is undefined with such" +
				"type of GeometricalObject");
	}
	
	public Vertex getEnd() throws NoSuchFieldException {
		if (this.go instanceof Edge) {
			return dir < 0 ? ((Edge) go).getStart() : ((Edge) go).getEnd();
		}
		throw new NoSuchFieldException("This method is undefined with such" +
				"type of GeometricalObject");
	}
}
